/* eslint-disable no-empty */
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.

import Vue from "vue";

import App from "./App";
import router from "./router";
import store from "./store/index";
import iView from "iview";
// import crypto from "crypto";
// import JQ from "jquery";
import VueWorker from "vue-worker";
import VueQriously from "vue-qriously";
import "iview/dist/styles/iview.css";
import Viewer from "v-viewer";
import "viewerjs/dist/viewer.css";
import VueCropper from "vue-cropper";
import VueLazyload from "vue-lazyload"; //懒加载
import VueVideoPlayer from "vue-video-player";
import VueClipboard from "vue-clipboard2"; // 粘贴板
// import axios from 'axios'
// import utilJs from './assets/util'
// import {keyPair,ws_encrypt,axios_encrypt,ws_decode} from './assets/encrypt/encrypt.js'
import "./utils/publicMethod.js";
import PinyinMatch from "pinyin-match"; // 简体中文拼音匹配插件
Vue.prototype.$pinyinMatch = PinyinMatch;

// Vue.prototype.$ws_decode = ws_decode;
import "../static/css/index.less";
import "../static/image/iconfont.css";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import { message } from "./assets/message";
import {
  imessage_error,
  imessage_info,
  imessage_loading,
  imessage_success,
  imessage_warning
} from "./assets/imessage";
require("video.js/dist/video-js.css");
require("vue-video-player/src/custom-theme.css");

Vue.prototype.$message = message;
iView.Message.warning = imessage_warning;
iView.Message.error = imessage_error;
iView.Message.info = imessage_info;
iView.Message.loading = imessage_loading;
iView.Message.success = imessage_success;
// import VuePreview from 'vue-preview'
// Vue.use(VuePreview)
if (
  process.env.NODE_ENV == "production" &&
  process.env.PROJECT_NAME == "online"
) {
  // console.log = function() {};
  // console.warn = function() {};
  // console.table = function() {};
}
Vue.use(VueVideoPlayer);
Vue.use(VueLazyload, {
  preLoad: 1.0,
  error: "static/image/home/errDefault.png"
});
Vue.use(ElementUI);
Vue.use(VueClipboard);
Vue.use(VueCropper);
Vue.use(Viewer);
Viewer.setDefaults({
  filter(image) {
    let src = image.getAttribute("viewer");
    let srcPath = image.getAttribute("src") || "a";
    return src == "true" &&
      srcPath.indexOf("yH5BAEAAAAALAAAAAABAAEAAAIBRAA7") == -1
      ? image
      : null;
  },
  zIndexInline: 9999,
  button: true,
  navbar: true,
  title: true,
  toolbar: true,
  tooltip: true,
  movable: true,
  zoomable: true,
  rotatable: true,
  scalable: true,
  transition: true,
  fullscreen: true,
  keyboard: true,
  url: "data-source"
});
Vue.use(iView);
Vue.use(VueQriously);
Vue.use(VueWorker);

console.log(Vue.prototype.$loginJsonString, 131112);

import filters from "./utils/filters";

filters(Vue);

Vue.config.productionTip = false;

/* eslint-disable no-new */
const vm = new Vue({
  el: "#app",
  router,
  store,
  components: {
    App
  },
  template: "<App/>"
});

window.WriteConsole = function(info) {
  console.log(info, "console");
};
window.ActivateMainForm = function() {
  // 激活窗体
  // window.external.InvokeWinFormMethod("Internal.Function","ActivateMainForm");
};
window.emithot = function(info) {
  let req = JSON.parse(info);
  store.state.copyImg = req;
  console.log(store.state.copyImg);
};

window.InternalFunction = function(info) {
  console.log(info, "闪烁调用 参数--->");
};

Vue.directive("drag", function(el) {
  let odiv = el; //当前元素
  odiv.onmousedown = e => {
    //算出鼠标相对元素的位置
    let disX = e.clientX - odiv.offsetLeft;
    let disY = e.clientY - odiv.offsetTop;
    document.onmousemove = e => {
      e.stopPropagation();
      //用鼠标的位置减去鼠标相对元素的位置，得到元素的位置
      let left = e.clientX - disX + 230;
      let top = e.clientY - disY + 120;
      if (left <= 230) {
        left = 230;
      }
      if (top <= 250) {
        top = 250;
      }
      if (top >= document.body.clientHeight) {
        top = document.body.clientHeight;
      }
      if (left + 240 >= document.body.clientWidth) {
        left = document.body.clientWidth - 240;
      }
      //移动当前元素
      odiv.style.left = left + "px";
      odiv.style.top = top + "px";
    };
    document.onmouseup = e => {
      document.onmousemove = null;
      document.onmouseup = null;
    };
  };
});


//消息提示
import { showMsg } from './utils/message.js'
Vue.prototype.$showMsg = showMsg
